library("tidyverse")
library("here")
library("assertthat")
library("VIM")
library("janitor")
library("ggstatsplot")
library("glue")
library("gt")
library("rstatix")
library("broom")
library("futile.logger")
library("gt")
library("infer")
conflicted::conflict_prefer("discard", "purrr")
conflicted::conflict_prefer("filter", "dplyr")
flog.appender(appender.file("covid-icu.log"))
flog.threshold(INFO)
flog.info("STARTING script 02")
flog.info("Logger inited")
source(here("src", "01-constants.R"))
source(here("src", "funs", "prepare-data.R"))
source(here("src", "funs", "helper-funs.R"))
source(here("src", "funs", "prop_NA.R"))
source(here("src", "funs", "compare_progression.R"))
source(here("src", "funs", "is_binary.R"))
if (params$dataset == "small") {
d <- read_csv(here("data", "processed", "data-small-prepared.csv"))
} else {
d <- read_csv(here("data", "processed", "data-prepared.csv"))
}
names_binary_vars <-
d %>%
keep(is_binary, na.rm = TRUE) %>%
names()
names_binary_vars
## [1] "verlauf"
## [2] "geschlecht"
## [3] "supportive_o2"
## [4] "fieber"
## [5] "husten"
## [6] "dyspnoe"
## [7] "geruchs_geschmacksverlust"
## [8] "kopfschm"
## [9] "gliederschm"
## [10] "abgeschlagenheit"
## [11] "schuttelfrost"
## [12] "halsschmerzen"
## [13] "diarrho_emesis"
## [14] "mutation"
## [15] "dm"
## [16] "adipositas"
## [17] "art_hypert"
## [18] "chron_herzerkr"
## [19] "asthma_bronchiale"
## [20] "nicht_asthmat_lungenerkr"
## [21] "chron_nierenerkrankung"
## [22] "nikotinabusus"
## [23] "maligne_vorerkrankung"
## [24] "ns_hf"
## [25] "niv"
## [26] "beatmung_imv"
## [27] "ecmo"
## [28] "dialyse"
## [29] "tod"
## [30] "sepsis"
## [31] "blutungen"
## [32] "resp_insuff"
## [33] "pneumonie_bakterielle_virale_fungale_superinfektion"
## [34] "kardiale_beteiligung_tara_vhf_mi"
## [35] "akutes_nierenversagen"
names_metric_vars <-
d %>%
keep(negate(~ is_binary(., na.rm = TRUE))) %>%
names()
names_metric_vars
## [1] "id" "alter"
## [3] "af" "sat_percent"
## [5] "hf" "bp_sys"
## [7] "bp_dia" "gcs"
## [9] "temp" "esi"
## [11] "q_sofa" "ven_bga_p_co2_mm_hg"
## [13] "vbga_p_o2_mm_hg" "ven_laktat_mmol_l"
## [15] "fi_o2_umgerechnet_percent" "leukos_nl"
## [17] "thrombos_nl" "neutros_nl"
## [19] "lymphos_nl" "nlr"
## [21] "quick_percent" "harnstoff_mg_dl"
## [23] "crea_mg_dl" "e_gfr_ml_min"
## [25] "bilirubin_ges_mg_d_l" "ast_u_l"
## [27] "alt_u_l" "ldh_u_l"
## [29] "crp_mg_d_l" "procalcitonin_ng_m_l"
## [31] "ro" "bg"
List of metric variables to be compared with regard to progress (bad/good):
cols_to_be_compared_metric <-
names_metric_vars %>%
discard(~ .x %in% c("fallnummer", "verlauf", "id"))
cols_to_be_compared_metric
## [1] "alter" "af"
## [3] "sat_percent" "hf"
## [5] "bp_sys" "bp_dia"
## [7] "gcs" "temp"
## [9] "esi" "q_sofa"
## [11] "ven_bga_p_co2_mm_hg" "vbga_p_o2_mm_hg"
## [13] "ven_laktat_mmol_l" "fi_o2_umgerechnet_percent"
## [15] "leukos_nl" "thrombos_nl"
## [17] "neutros_nl" "lymphos_nl"
## [19] "nlr" "quick_percent"
## [21] "harnstoff_mg_dl" "crea_mg_dl"
## [23] "e_gfr_ml_min" "bilirubin_ges_mg_d_l"
## [25] "ast_u_l" "alt_u_l"
## [27] "ldh_u_l" "crp_mg_d_l"
## [29] "procalcitonin_ng_m_l" "ro"
## [31] "bg"
cols_to_be_compared_metric %>%
map(~ compare_progression_metric(d,
group = verlauf,
var = .))
Starting analysis for variable: alter
Grouping variable: verlauf
End of analysis for variable: alter
Starting analysis for variable: af
Grouping variable: verlauf
End of analysis for variable: af
Starting analysis for variable: sat_percent
Grouping variable: verlauf
End of analysis for variable: sat_percent
Starting analysis for variable: hf
Grouping variable: verlauf
End of analysis for variable: hf
Starting analysis for variable: bp_sys
Grouping variable: verlauf
End of analysis for variable: bp_sys
Starting analysis for variable: bp_dia
Grouping variable: verlauf
End of analysis for variable: bp_dia
Starting analysis for variable: gcs
Grouping variable: verlauf
End of analysis for variable: gcs
Starting analysis for variable: temp
Grouping variable: verlauf
End of analysis for variable: temp
Starting analysis for variable: esi
Grouping variable: verlauf
End of analysis for variable: esi
Starting analysis for variable: q_sofa
Grouping variable: verlauf
End of analysis for variable: q_sofa
Starting analysis for variable: ven_bga_p_co2_mm_hg
Grouping variable: verlauf
End of analysis for variable: ven_bga_p_co2_mm_hg
Starting analysis for variable: vbga_p_o2_mm_hg
Grouping variable: verlauf
End of analysis for variable: vbga_p_o2_mm_hg
Starting analysis for variable: ven_laktat_mmol_l
Grouping variable: verlauf
End of analysis for variable: ven_laktat_mmol_l
Starting analysis for variable: fi_o2_umgerechnet_percent
Grouping variable: verlauf
End of analysis for variable: fi_o2_umgerechnet_percent
Starting analysis for variable: leukos_nl
Grouping variable: verlauf
End of analysis for variable: leukos_nl
Starting analysis for variable: thrombos_nl
Grouping variable: verlauf
End of analysis for variable: thrombos_nl
Starting analysis for variable: neutros_nl
Grouping variable: verlauf
End of analysis for variable: neutros_nl
Starting analysis for variable: lymphos_nl
Grouping variable: verlauf
End of analysis for variable: lymphos_nl
Starting analysis for variable: nlr
Grouping variable: verlauf
End of analysis for variable: nlr
Starting analysis for variable: quick_percent
Grouping variable: verlauf
End of analysis for variable: quick_percent
Starting analysis for variable: harnstoff_mg_dl
Grouping variable: verlauf
End of analysis for variable: harnstoff_mg_dl
Starting analysis for variable: crea_mg_dl
Grouping variable: verlauf
End of analysis for variable: crea_mg_dl
Starting analysis for variable: e_gfr_ml_min
Grouping variable: verlauf
End of analysis for variable: e_gfr_ml_min
Starting analysis for variable: bilirubin_ges_mg_d_l
Grouping variable: verlauf
End of analysis for variable: bilirubin_ges_mg_d_l
Starting analysis for variable: ast_u_l
Grouping variable: verlauf
End of analysis for variable: ast_u_l
Starting analysis for variable: alt_u_l
Grouping variable: verlauf
End of analysis for variable: alt_u_l
Starting analysis for variable: ldh_u_l
Grouping variable: verlauf
End of analysis for variable: ldh_u_l
Starting analysis for variable: crp_mg_d_l
Grouping variable: verlauf
End of analysis for variable: crp_mg_d_l
Starting analysis for variable: procalcitonin_ng_m_l
Grouping variable: verlauf
End of analysis for variable: procalcitonin_ng_m_l
Starting analysis for variable: ro
Grouping variable: verlauf
End of analysis for variable: ro
Starting analysis for variable: bg
Grouping variable: verlauf
End of analysis for variable: bg
[[1]] NULL
[[2]] NULL
[[3]] NULL
[[4]] NULL
[[5]] NULL
[[6]] NULL
[[7]] NULL
[[8]] NULL
[[9]] NULL
[[10]] NULL
[[11]] NULL
[[12]] NULL
[[13]] NULL
[[14]] NULL
[[15]] NULL
[[16]] NULL
[[17]] NULL
[[18]] NULL
[[19]] NULL
[[20]] NULL
[[21]] NULL
[[22]] NULL
[[23]] NULL
[[24]] NULL
[[25]] NULL
[[26]] NULL
[[27]] NULL
[[28]] NULL
[[29]] NULL
[[30]] NULL
[[31]] NULL
cols_to_be_compared_binary <-
names_binary_vars %>%
discard(~ .x %in% c("fallnr", "verlauf"))
d_factor <-
d %>%
select(verlauf, all_of(cols_to_be_compared_binary)) %>%
mutate(across(everything(),
factor))
ggpiestats(data = d, x = verlauf, y = ns_hf, bf.message = FALSE, title = "ns_hf")
ggpiestats(data = d, x = verlauf, y = niv, bf.message = FALSE, title = "niv")
ggpiestats(data = d, x = verlauf, y = resp_insuff, bf.message = FALSE, title = "resp_insuff")
ggpiestats(data = d, x = verlauf, y = beatmung_imv, bf.message = FALSE, title = "beatmung_imv")
ggpiestats(data = d, x = verlauf, y = pneumonie_bakterielle_virale_fungale_superinfektion, bf.message = FALSE, title = "pneumonie_bakterielle_virale_fungale_superinfektion")
ggpiestats(data = d, x = verlauf, y = sepsis, bf.message = FALSE, title = "sepsis")
ggpiestats(data = d, x = verlauf, y = kardiale_beteiligung_tara_vhf_mi, bf.message = FALSE, title = "kardiale_beteiligung_tara_vhf_mi")
ggpiestats(data = d, x = verlauf, y = tod, bf.message = FALSE, title = "tod")
ggpiestats(data = d, x = verlauf, y = dyspnoe, bf.message = FALSE, title = "dyspnoe")
ggpiestats(data = d, x = verlauf, y = nikotinabusus, bf.message = FALSE, title = "nikotinabusus")
ggpiestats(data = d, x = verlauf, y = art_hypert, bf.message = FALSE, title = "art_hypert")
ggpiestats(data = d, x = verlauf, y = dm, bf.message = FALSE, title = "dm")
ggpiestats(data = d, x = verlauf, y = geschlecht, bf.message = FALSE, title = "geschlecht")
ggpiestats(data = d, x = verlauf, y = kopfschm, bf.message = FALSE, title = "kopfschm")
ggpiestats(data = d, x = verlauf, y = adipositas, bf.message = FALSE, title = "adipositas")